package com.ali.config;

import com.ali.api.PayApi;
import com.ali.common.Response;
import com.ali.common.ReturnEnum;
import com.ali.dto.PayInfo;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 自定义统一服务降级处理器
 */
@Component
public class MyOpenFeignFallBackHandler implements PayApi {
    @Override
    public Response<List<PayInfo>> query(Map<String, Object> param) {
        return Response.fail(ReturnEnum.RC999.getCode(), "服务调用失败");
    }

    @Override
    public Response<String> timeout() {
        return Response.fail(ReturnEnum.RC999.getCode(), "服务调用失败");
    }

    @Override
    public Response<String> control(Map<String, Object> param) {
        return Response.fail(ReturnEnum.RC999.getCode(), "服务调用失败");
    }

    @Override
    public Response<String> print(Map<String, Object> param, Map<String, Object> header) {
        return Response.fail(ReturnEnum.RC999.getCode(), "服务调用失败");
    }

    @Override
    public Response<String> add(Map<String, Object> param) {
        throw new RuntimeException("服务调用失败");
    }
}
